SetCompressor lzma

!define JRE_VERSION "1.6"
!define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52252"
!include "MUI2.nsh"
!include "JREDyna_Inetc.nsh"

Name "Carassius"
OutFile "Carassius-0.5.5-beta.exe"

InstallDir "$PROGRAMFILES\Carassius"

!insertmacro MUI_PAGE_DIRECTORY
!insertmacro CUSTOM_PAGE_JREINFO
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE	"Carassius 0.5.5 is now installed!"
!define MUI_FINISHPAGE_TEXT	"You can now begin managing your fish tanks."
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT	"Start Carassius"
!define MUI_FINISHPAGE_RUN_FUNCTION	"Launch"
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_COMPONENTS
!insertmacro MUI_UNPAGE_INSTFILES
!define MUI_FINISHPAGE_TITLE "Carassius is now removed!"
!define MUI_FINISHPAGE_TEXT	"Thanks for using this program."
!insertmacro MUI_UNPAGE_FINISH

Function Launch
  ExecShell "" "$SMPROGRAMS\Carassius\Carassius.lnk"
FunctionEnd

Section "Carassius"
  call DownloadAndInstallJREIfNecessary
  setOutPath	$INSTDIR

  file	"Carassius.jar"

  createDirectory	"$INSTDIR\lib"
  setOutPath	"$INSTDIR\lib"

  file	"lib\appframework-1.0.3.jar"
  file	"lib\hsqldb.jar"
  file	"lib\jcalendar-1.3.3.jar"
  file	"lib\swing-worker-1.1.jar"

  writeUninstaller	"$INSTDIR\uninstall.exe"

  createDirectory	"$SMPROGRAMS\Carassius"
  createShortCut	"$SMPROGRAMS\Carassius\Carassius verwijderen.lnk" "$INSTDIR\uninstall.exe"
  createShortCut	"$SMPROGRAMS\Carassius\Carassius.lnk" "$INSTDIR\Carassius.jar"

  WriteRegStr	HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Carassius" \
		"DisplayName" "Carassius 0.5.5 beta"
  WriteRegStr	HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Carassius" \
		"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
SectionEnd

Section "un.Carassius"
  SectionIn RO

  DeleteRegKey	HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Carassius"

  rmdir	/r	"$SMPROGRAMS\Carassius"

  rmdir	/r	$INSTDIR
SectionEnd

Section "un.Settings" Settings
  rmdir	/r	"$PROFILE\.carassius"
SectionEnd

LangString DESC_Settings ${LANG_ENGLISH} "Settings and database created by Carassius."

!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${Settings} $(DESC_Settings)
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
